home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name pcalloc -- Allocate memory
- *
- * Synopsis ercode = pcalloc(request,pseg,psize);
- * int ercode Returned error code
- * unsigned request Number of paragraphs requested
- * unsigned *pseg Segment address of allocated block
- * unsigned *psize Size in paragraphs of allocated block
- *
- * Description pcalloc allocates a block of memory of request paragraphs
- * (16 bytes). The next (highest in memory) available block
- * of memory is allocated, and the starting segment address
- * is returned. If more memory is requested than is available,
- * the amount of available memory is returned, but no block is
- * actually allocated.
- *
- * Returns ercode Returned DOS 2.0 error code.
- * pseg Segment address of memory block allocated.
- * psize Size in paragraphs of memory block which
- * is allocated, or the available memory size.
- *
- * Version 1.1 (C)Copyright Blaise Computing Inc. 1983, 1984
- *
- **/
-
- struct dreg
- {
- unsigned ax,bx,cx,dx,si,di,ds,es;
- };
-
- int pcalloc(request,pseg,psize)
- unsigned request,*pseg,*psize;
- {
-
- struct dreg dos_reg;
- int ercode,dos();
-
- utinit(&dos_reg); /* Initialize the registers */
- dos_reg.ax = 0x4800;
- dos_reg.bx = request;
- ercode = dos(&dos_reg); /* Invoke DOS function 48h */
- *pseg = 0xffff; /* Initialize to bad address */
- if (ercode == 0)
- {
- *pseg = dos_reg.ax; /* Segment address */
- *psize = dos_reg.bx; /* Segment size */
- }
- else if (ercode == 8)
- *psize = dos_reg.bx; /* Insufficient memory */
- else
- *psize = 0;
-
- return(ercode);
-
- }